package com.innerchic.weqiuqiu.ui;

import android.content.Intent;
import android.text.Html;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;

import androidx.annotation.NonNull;
import androidx.appcompat.app.ActionBar;

import com.innerchic.annotations.base.ActivitySetting;
import com.innerchic.annotations.base.BindActivityLayoutHolder;
import com.innerchic.mapper.app.SuperActivity;
import com.innerchic.weqiuqiu.R;

/**
 * ================================================
 * 作    者：贾恒飞 >>> 17515250730@163.com
 * 项    目：wedudu
 * 日    期：2022/1/14 10:07
 * 包    名：com.innerchic.weqiuqiu.ui
 * 描    述：文本页面
 * Create by zFox from AndroidStudio4.2
 * ================================================
 */
@BindActivityLayoutHolder
@ActivitySetting(layout = "activity_text", modificationActionBar = false, textTheme = true, swipe = true)
public class TextActivity extends SuperActivity {

    private TextActivityLayoutHolder holder;

    @Override
    public void create() {
        Intent intent = getIntent();
        String page_title = intent.getStringExtra("page_title");
        ActionBar actionBar = getSupportActionBar();
        if (actionBar != null) {
            getSupportActionBar().setTitle(Html.fromHtml("<font color='#000'>" + page_title + "</font>"));
        }

        String content_text_info = intent.getStringExtra("content_text_info");
        boolean is_format_html = intent.getBooleanExtra("is_format_html", false);
        if (is_format_html) {
            holder.contentText.setText(Html.fromHtml(content_text_info));
        } else {
            holder.contentText.setText(content_text_info);
        }
    }

    @Override
    public void destroy() {

    }

    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        MenuInflater inflater = getMenuInflater();
        inflater.inflate(R.menu.close_menu, menu);
        return true;
    }

    @Override
    public boolean onOptionsItemSelected(@NonNull MenuItem item) {
        if (item.getItemId() == R.id.action_close) {
            finish();
        }
        return super.onOptionsItemSelected(item);
    }
}
